- name: make the app be real
  hosts: os_control[0]:os_control_stg[0]
  user: root
  gather_facts: False
  vars:
    app: mote
  vars_files:
    - /srv/web/infra/ansible/vars/global.yml
    - "/srv/private/ansible/vars.yml"
    - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  roles:
  - role: openshift/project
    description: Mote v2
    appowners:
    - darknao
    - t0xic0der
    tags:
    - appowners

  - role: openshift/imagestream
    imagename: mote

  - role: openshift/object
    template: buildconfig.yml
    objectname: buildconfig.yml

  - role: openshift/object
    template: mote-dc.yml
    objectname: mote-dc.yml

  - role: openshift/object
    template: mote-worker-dc.yml
    objectname: mote-worker-dc.yml

  # meetbot is not advertising on fedmsg.stg
  - role: openshift/object
    template: fedmsg-dc.yml
    objectname: fedmsg-dc.yml
    when: env == "production"

  - role: openshift/object
    template: redis-is.yml
    objectname: redis-is.yml

  - role: openshift/object
    template: redis-dc.yml
    objectname: redis-dc.yml

  - role: openshift/object
    template: redis-svc.yml
    objectname: redis-svc.yml

  - role: openshift/object
    template: mote-svc.yml
    objectname: mote-svc.yml

  - role: openshift/object
    template: mote-cm.yml
    objectname: mote-cm.yml

  - role: openshift/object
    template: secret.yml
    objectname: secret.yml

  - role: openshift/object
    template: fedmsg-cm.yml
    objectname: fedmsg-cm.yml
    when: env == "production"

  - role: openshift/object
    template: pvc.yml
    objectname: pvc.yml

  - role: openshift/route
    routename: mote
    serviceport: mote-tcp
    servicename: mote
    host: "meetbot{{ env_suffix }}.fedoraproject.org"
    annotations:
      haproxy.router.openshift.io/set-forwarded-headers: append

  - role: openshift/start-build
    buildname: mote
    objectname: mote

#
###############################################
# actions to delete the project from OpenShift
###############################################
# to run: sudo rbac-playbook -l os_control_stg[0] -t delete openshift-apps/mote.yml
  - role: openshift/object-delete
    objecttype: project
    objectname: mote
    tags:
    - never
    - delete
